import time
from quote.base.operationbrowser import OperationBrowser
from quote.base.userbrowser import UseBrowser
from quote.util.operationxel import OperationExl
from quote.util.operationyaml import OperationnYaml


class LoginPage:
    def __init__(self):
        self.ub = UseBrowser("chrome", "../../../chromedriver.exe")
        self.ob = OperationBrowser(UseBrowser.driver)
        self.oe = OperationExl()
        self.oy=OperationnYaml()


    def login(self,usernamr="",password=""):
        self.ob.open_url(self.oe.get_cell_value(1,1))
        self.ob.input_text_name("name",self.oy.get_locator('LoginPage','username'),usernamr)
        self.ob.input_text_name("name",self.oy.get_locator('LoginPage','passeord'), password)
        self.ob.click_name("name",self.oy.get_locator('LoginPage','submit'))
        # time.sleep(5)
    # 成功
    def get_suc_text(self):
        self.ob.change_frame(self.oy.get_locator('LoginPage','framemain'))
        return self.ob.get_text_xpath(self.oy.get_locator('LoginPage','sucinfo'))
    def get_fail_text(self):
        return self.ob.get_text_xpath(self.oy.get_locator('LoginPage','failinfo'))


# if __name__=="__main__":
#     longinpage=LoginPage()
#     longinpage.login("admin","admin")
#     UseBrowser.quit()
